package powierzchnie1;

import powierzchnie.*;
import javax.vecmath.Point3d;
import javax.vecmath.Vector3d;

/**
 *
 * @author Arek
 */
public class Plaszczyzna {

    private double A;
    private double B;
    private double C;
    private double D;

    public Plaszczyzna(double A, double B, double C, double D) {
        this.A = A;
        this.B = B;
        this.C = C;
        this.D = D;
    }

    public Plaszczyzna(Vector3d v, Point3d sm) {
        this.A = v.x;
        this.B = v.y;
        this.C = v.z;
        this.D = -(v.x * sm.x + v.y * sm.y + v.z * sm.z);

    }

    double odleglosc(Point3d p) {
        return Math.abs(this.A * p.x + this.B * p.y + this.C * p.z + this.D) /
                Math.sqrt(this.A * this.A + this.B * this.B + this.C * this.C);
    }

//=====================================================
    // Metody typu GetCosTam.
//====================================================
    public double getA() {
        return A;
    }

    public double getB() {
        return B;
    }

    public double getC() {
        return C;
    }

    public double getD() {
        return D;
    }
//---------------------------------------------------------  
    @Override
    public String toString(){
       return "[" + this.A + "; " + this.B + "; " + this.C + "; " + this.D +"]";
    }
}
